/**
 * 项目名：phms3
 * 日期：    2019-11-23 11:17:07
 * Copyright (c) 2015- HTSC-版权所有
 */

package com.joysuch.wwyt.core.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "WWYT_BASE_MENU_FUNCTION")
@SQLDelete(sql = "update WWYT_BASE_MENU_FUNCTION set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_BASE_MENU_FUNCTION set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
public class BaseMenuFunction implements java.io.Serializable {

    // columns START
    // ID
    private Long id;
    // 名称
    private String name;
    // 租户
    private Long tenentId;
    // 深度
    private Integer depth;
    // URL
    private String url;
    // 类型
    private String type;

    private String perm;
    // // 父功能ID
    // private java.lang.Long parentId;
    // 顺序
    private Integer showOrder;
    // 图标
    private String icon;
    // 创建人
    private Long createBy;
    // 创建时间
    private java.util.Date createTime;
    // 更新人
    private Long updateBy;
    // 更新时间
    private java.util.Date updateTime;
    // 删除标记
    private String deleteFlag;
    // 组织机构代码
    private String orgCode;

    private BaseMenuFunction parent;
    // columns END
    private Integer menuOrder;
    //业务流程ID
    private Long workFlowId;
    //主页快捷图标
    private String dashboardIcon;
    // 快捷大屏图标
    private Long fastScreenImgId;
    //菜单是否显示:0隐藏;1显示
    private Integer showState;
    //是否是app菜单名称:是;否
    private String appFlag;
    //app菜单名称
    private String appName;

    private List<BaseMenuFunction> childList;


    //包表统计id
    private Long inquiryId;
    //app菜单路由
    private String appMenuUrl;

    //新版流程引擎模型id
    private String modelId;

    //是否打开新窗口, 默认否 （0=否， 1=是）
    private Integer openNewWindow;

    @Column(name = "inquiry_id")
    public Long getInquiryId() {
        return inquiryId;
    }

    public void setInquiryId(Long inquiryId) {
        this.inquiryId = inquiryId;
    }

    @Transient
    public List<BaseMenuFunction> getChildList() {
        return childList;
    }

    public void setChildList(List<BaseMenuFunction> childList) {
        this.childList = childList;
    }

    @Column(name = "show_state")
    public Integer getShowState() {
        return showState;
    }

    public void setShowState(Integer showState) {
        this.showState = showState;
    }

    public void setId(Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public Long getId() {
        return this.id;
    }

    @Column(name = "NAME", length = 50)
    public String getName() {
        return this.name;
    }

    public void setName(String value) {
        this.name = value;
    }

    @Column(name = "TENENT_ID")
    public Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(Long value) {
        this.tenentId = value;
    }

    @Column(name = "URL", length = 500)
    public String getUrl() {
        return this.url;
    }

    public void setUrl(String value) {
        this.url = value;
    }

    @Column(name = "PERM", length = 50)
    public String getPerm() {
        return perm;
    }

    public void setPerm(String perm) {
        this.perm = perm;
    }

    @Column(name = "TYPE", length = 10, nullable = false)
    public String getType() {
        return this.type;
    }

    public void setType(String value) {
        this.type = value;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PARENT_ID")
    @JsonIgnore
    public BaseMenuFunction getParent() {
        return parent;
    }

    public void setParent(BaseMenuFunction parent) {
        this.parent = parent;
    }

    @Column(name = "SHOW_ORDER")
    public Integer getShowOrder() {
        return this.showOrder;
    }

    public void setShowOrder(Integer value) {
        this.showOrder = value;
    }

    @Column(name = "ICON", length = 50)
    public String getIcon() {
        return this.icon;
    }

    public void setIcon(String value) {
        this.icon = value;
    }

    @Column(name = "MENU_ORDER")
    public Integer getMenuOrder() {
        return menuOrder;
    }

    public void setMenuOrder(Integer menuOrder) {
        this.menuOrder = menuOrder;
    }

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(Long value) {
        this.createBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.util.Date value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.util.Date value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(String value) {
        this.deleteFlag = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(String value) {
        this.orgCode = value;
    }

    public Integer getDepth() {
        return depth;
    }

    public void setDepth(Integer depth) {
        this.depth = depth;
    }

    @Transient
    public boolean isMenu() {
        return "menu".equals(type);
    }

    @Transient
    public boolean isFolder() {
        return "folder".equals(type);
    }

    @Transient
    public boolean isButton() {
        return "button".equals(type);
    }

    public Long getWorkFlowId() {
        return workFlowId;
    }

    @Column(name = "WORK_FLOW_ID")
    public void setWorkFlowId(Long workFlowId) {
        this.workFlowId = workFlowId;
    }

    @Column(name = "DASHBOARD_ICON", length = 100)
    public String getDashboardIcon() {
        return dashboardIcon;
    }

    public void setDashboardIcon(String dashboardIcon) {
        this.dashboardIcon = dashboardIcon;
    }

    @Column(name = "app_flag")
    public String getAppFlag() {
        return appFlag;
    }

    public void setAppFlag(String appFlag) {
        this.appFlag = appFlag;
    }

    @Column(name = "app_name")
    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    @Column(name = "app_menu_url")
    public String getAppMenuUrl() {
        return appMenuUrl;
    }

    public void setAppMenuUrl(String appMenuUrl) {
        this.appMenuUrl = appMenuUrl;
    }

    @Column(name = "fast_screen_img_id")
    public Long getFastScreenImgId() {
        return fastScreenImgId;
    }

    public void setFastScreenImgId(Long fastScreenImg) {
        this.fastScreenImgId = fastScreenImg;
    }

    @Column(name = "model_id")
    public String getModelId() {
        return modelId;
    }

    public void setModelId(String modelId) {
        this.modelId = modelId;
    }

    @Column(name = "OPEN_NEW_WINDOW" )
    public Integer getOpenNewWindow() { return openNewWindow; }

    public void setOpenNewWindow(Integer openNewWindow) {this.openNewWindow = openNewWindow; }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("name", getName())
                .append("tenentId", getTenentId()).append("url", getUrl()).append("type", getType())
                .append("showOrder", getShowOrder()).append("icon", getIcon()).append("createBy", getCreateBy())
                .append("createTime", getCreateTime()).append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime()).append("deleteFlag", getDeleteFlag())
                .append("orgCode", getOrgCode()).append("showState", getShowState())
                .append("openNewWindow", getOpenNewWindow()).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BaseMenuFunction == false)
            return false;
        if (this == obj)
            return true;
        BaseMenuFunction other = (BaseMenuFunction) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
